/**
 * 
 */
package src.base;

import java.util.Random;
import java.util.Vector;

public class Source {

	public int index = 0;
	public int seed;
	public int range;
	public Vector<Element> source;
	
	public Source(int seed, int range, int samples)
	{
		this.seed = seed;
		this.range = range;
		generateSource(samples);
	}
	
	public void generateSource(int samples)
	{
		Random aNumber =  new Random(seed);
		source = new Vector<Element>();
		for (int i = 0; i < samples; i++)
		{
			source.add(new Element(aNumber.nextInt(range)));
		}
	}
	
	public void moveIndexOf(int gauss_number)
	{
		try 
		{
			if (index < 0) throw new IllegalArgumentException("Index must be > 0");
			index = index + gauss_number;
		}
		catch (IllegalArgumentException e) {
			System.err.println(e.getMessage());
		}
	}
		
	public int getIndex()
	{
		return index;
	}
	
	public Vector<Element> getSource()
	{
		return source;
	}

	public int getRange() 
	{
		return range;
	}
	
	public int getSeed() 
	{
		return this.seed;
	}
	
	public String toString()
	{
		int left = source.size() - index;
		return "Source (" + left + ")";
	}
	
}
